package com.hex.ds.hdtp.core.app.script.analyze.service.impl;

import com.hex.ds.hdtp.core.app.script.analyze.converter.IScriptAnalyzeTransferConverter;
import com.hex.ds.hdtp.core.app.script.analyze.dto.response.ScriptAnalyzeTransferResponseDto;
import com.hex.ds.hdtp.core.app.script.analyze.service.IScriptAnalyzeTransferService;
import com.hex.ds.hdtp.core.inf.script.analyze.po.ScriptAnalyzeTransferPo;
import com.hex.ds.hdtp.core.inf.script.analyze.repository.IScriptAnalyzeTransferRepository;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Package com.hex.ds.hdtp.core.app.script.analyze.service.impl
 * @ClassName ScriptAnalyzeTransferService
 * @Description 脚本分析任务和各迁移模块任务关系-业务接口实现
 * @Author gj.xu
 * @Date 2023/12/8 16:17
 * @Version v2.0
 **/
@Slf4j
@Service
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class ScriptAnalyzeTransferService implements IScriptAnalyzeTransferService {

    private final IScriptAnalyzeTransferConverter converter;

    private final IScriptAnalyzeTransferRepository scriptAnalyzeTransferRepository;

    /**
     * @Method queryListByAnalyzeTaskId
     * @Param analyzeTaskPkId
     * @Return java.util.List<com.hex.ds.hdtp.core.app.script.analyze.dto.response.ScriptAnalyzeTransferResponseDto>
     * @Description 根据分析任务主键查询
     * @Author gj.xu
     * @Date 2023/12/12 16:07
     * @Version V2.0
     */
    @Override
    public List<ScriptAnalyzeTransferResponseDto> queryListByAnalyzeTaskId(String analyzeTaskPkId) {
        return converter.toScriptAnalyzeTransferResponseDtoList(scriptAnalyzeTransferRepository.queryListByAnalyzeTaskId(analyzeTaskPkId));
    }

    /**
     * @Method add
     * @Param
     * @Param analyzeTaskPkId
     * @Param transferTaskPkId
     * @Param transferTaskType
     * @Return int
     * @Description 新增
     * @Author gj.xu
     * @Date 2023/12/8 16:47
     * @Version V2.0
     */
    @Override
    public int add(String analyzeTaskPkId, String transferTaskPkId, String transferTaskType) {
        ScriptAnalyzeTransferPo scriptAnalyzeTransferPo = new ScriptAnalyzeTransferPo()
                .setAnalyzeTaskPkId(analyzeTaskPkId)
                .setTransferTaskPkId(transferTaskPkId)
                .setTransferTaskType(transferTaskType);
        return scriptAnalyzeTransferRepository.add(scriptAnalyzeTransferPo);
    }

    /**
     * @Method removeByAnalyzeTaskId
     * @Param
     * @Param analyzeTaskPkId
     * @Return java.lang.Integer
     * @Description 根据分析任务主键删除
     * @Author gj.xu
     * @Date 2023/12/8 16:47
     * @Version V2.0
     */
    @Override
    public Integer removeByAnalyzeTaskId(String analyzeTaskPkId) {
        return scriptAnalyzeTransferRepository.removeByAnalyzeTaskId(analyzeTaskPkId);
    }
}
